#pragma once

#include "SceneNodeProperties.h"



enum NODE_TYPE
{
	NODE_ENTITY_ELEMENT = 1,
	NODE_POSITION_REF = 2

};


enum ENTITY_TYPE
{
	ENTITY_GHOST = 0,
	ENTITY_MESH = 1,
	ENTITY_SPRITE = 2,
	ENTITY_TEXT = 3
};


class CSceneNode: public CSceneNodeProperties
{
	private:
		CSceneNode*		_parent;
		UINT			_nodeHash;
		char*			_nodeDisplayName;
		bool			_inSceneGraph;


	protected:
		NODE_TYPE		_type;
		ENTITY_TYPE		_entity;

		float			DeltaTime;

	public:
		CSceneNode(): _parent(NULL) 
		{
			_inSceneGraph = false;
			_type = NODE_ENTITY_ELEMENT;
			_entity = ENTITY_GHOST;
			_nodeDisplayName = "unknown node";
			DeltaTime = 0.0f;
		}

		~CSceneNode() {}


		friend class CSceneGraph;

		
		bool AttachToNode(CSceneNode* attach) 
		{ 
			if(attach != NULL &&
				attach->IsInScene())
			{
				_parent = attach;
				return true;
			}
			
			return false;
		}


		void Update(float dt)
		{
			DeltaTime = dt;
			UpdateNode();
		}

		virtual void UpdateNode() {};


		CSceneNode* GetParent()		const { return _parent; }
		NODE_TYPE	GetType()		const { return _type; }
		ENTITY_TYPE	GetEntityType()	const { return _entity; }
		bool		IsInScene()		const { return _inSceneGraph; }
		char*		GetNodeName()	const { return _nodeDisplayName; }


		virtual void Release() {};


		//interface
		virtual bool IsRenderable() { return false; };
		
		
		bool operator < (const CSceneNode &rhd) const
		{
			return _type < rhd.GetType();
		}
};
